package com.sqmx.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sqmx.common.annotation.Log;
import com.sqmx.common.core.controller.BaseController;
import com.sqmx.common.core.domain.AjaxResult;
import com.sqmx.common.enums.BusinessType;
import com.sqmx.base.domain.SqmxPet;
import com.sqmx.base.service.ISqmxPetService;
import com.sqmx.common.utils.poi.ExcelUtil;
import com.sqmx.common.core.page.TableDataInfo;

/**
 * 宠物基础信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/base/pet")
public class SqmxPetController extends BaseController
{
    @Autowired
    private ISqmxPetService sqmxPetService;

    /**
     * 查询宠物基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:pet:list')")
    @GetMapping("/list")
    public TableDataInfo list(SqmxPet sqmxPet)
    {
        startPage();
        List<SqmxPet> list = sqmxPetService.selectSqmxPetList(sqmxPet);
        return getDataTable(list);
    }

    /**
     * 导出宠物基础信息列表
     */
    @PreAuthorize("@ss.hasPermi('base:pet:export')")
    @Log(title = "宠物基础信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SqmxPet sqmxPet)
    {
        List<SqmxPet> list = sqmxPetService.selectSqmxPetList(sqmxPet);
        ExcelUtil<SqmxPet> util = new ExcelUtil<SqmxPet>(SqmxPet.class);
        util.exportExcel(response, list, "宠物基础信息数据");
    }

    /**
     * 获取宠物基础信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:pet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sqmxPetService.selectSqmxPetById(id));
    }

    /**
     * 新增宠物基础信息
     */
    @PreAuthorize("@ss.hasPermi('base:pet:add')")
    @Log(title = "宠物基础信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SqmxPet sqmxPet)
    {
        return toAjax(sqmxPetService.insertSqmxPet(sqmxPet));
    }

    /**
     * 修改宠物基础信息
     */
    @PreAuthorize("@ss.hasPermi('base:pet:edit')")
    @Log(title = "宠物基础信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SqmxPet sqmxPet)
    {
        return toAjax(sqmxPetService.updateSqmxPet(sqmxPet));
    }

    /**
     * 删除宠物基础信息
     */
    @PreAuthorize("@ss.hasPermi('base:pet:remove')")
    @Log(title = "宠物基础信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sqmxPetService.deleteSqmxPetByIds(ids));
    }
}
